<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="layout_backend/base_layout">

<style layout:fragment="css">
</style>

<div layout:fragment="content">
	<form id="form">
	<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" lay-reqtext="文章标题不能为空" placeholder="请输入文章标题" th:value="${vo?.title}" class="layui-input">
        </div>
    </div>
   <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="正常|已删除">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
        	<!-- 加载编辑器的容器 -->
		    <textarea id="container" name="content" type="text/plain" th:text="${vo?.content}"></textarea>
		    <!-- 配置文件 -->
		    <script type="text/javascript" src="/backend/js/ueditor/ueditor.config.js"></script>
		    <script type="text/javascript" src="/backend/js/ueditor/ueditor.all.js"></script>
		    <script type="text/javascript">
		        var ue = UE.getEditor('container', {
		            autoHeight: true
		        });/* 
		        $(document).ready(function () {alert(1);
		            var value = $("#hfText").val();
		            UM.getEditor('myEditor').setContent(value, false);
		        });
		        var SetValue = function () {
		            var value = UM.getEditor('myEditor').getContent();
		            $("#hfText").val(value);            
		        }; */
		    </script>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
        	 <input type="hidden" name="id" th:value="${vo?.id}">
            <button class="layui-btn" lay-submit lay-filter="saveBtn" type="submit">确认保存</button>
        </div>
    </div>
    </div>
	</form>
</div>

<script layout:fragment="script">
layui.use(['form'], function () {
    var form = layui.form,
        layer = layui.layer,
        $ = layui.$;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
        var data = $('#form').serialize();
        $.ajax({
           url: "save",
           method: "post",
           data: data,
           success: function(){
                parent.layui.table.reload('currentTableId');
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);
           }
        });
        return false;
    }); 


});
</script>

</html>